package com.spy.material.controller;

import com.spy.common.core.domain.R;
import com.spy.material.dto.OutboundOrderCreateDTO;
import com.spy.material.dto.OutboundOrderQueryDTO;
import com.spy.material.service.IOutboundOrderDetailService;
import com.spy.material.vo.OutboundOrderDetailVO;
import com.spy.material.vo.OutboundOrderPageVO;
import com.spy.material.vo.OutboundOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spy.common.annotation.Log;
import com.spy.common.core.controller.BaseController;
import com.spy.common.core.domain.AjaxResult;
import com.spy.common.enums.BusinessType;
import com.spy.material.domain.OutboundOrder;
import com.spy.material.service.IOutboundOrderService;
import com.spy.common.utils.poi.ExcelUtil;
import com.spy.common.core.page.TableDataInfo;

/**
 * 出库管理Controller
 *
 * @author twc
 * @date 2025-11-09
 */
@RestController
@RequestMapping("/material/outbounds")
@Api(tags = "出库管理相关接口")
public class OutboundOrderController extends BaseController
{
    @Autowired
    private IOutboundOrderService outboundOrderService;
    @Autowired
    private IOutboundOrderDetailService outboundOrderDetailService;

    @ApiOperation("分页查询出库管理列表")
    @GetMapping("/page")
    public R<OutboundOrderPageVO> page(OutboundOrderQueryDTO outboundOrderQueryDTO){
         OutboundOrderPageVO outboundOrderPageVO =outboundOrderService.all(outboundOrderQueryDTO);
         return R.ok(outboundOrderPageVO);
    }

    @ApiOperation("新增出库管理")
    @PostMapping("/add")
    public R add(@RequestBody OutboundOrderCreateDTO outboundOrderCreateDTO){
        outboundOrderService.add(outboundOrderCreateDTO);
        return R.ok();
    }

    @ApiOperation("出库明细详情")
    @GetMapping("/detail/{outboundOrderId}")
    public R<List<OutboundOrderDetailVO>> detail(@PathVariable Long outboundOrderId){
        List<OutboundOrderDetailVO>  outboundOrderDetailVOList = outboundOrderDetailService.detail(outboundOrderId);
        return R.ok(outboundOrderDetailVOList);
    }
}